import socket
import time

def ROVDirectionControl(temp):
    X,T,W,H=temp
    udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    ip_adders = ('192.168.137.2', 8008)
    # 中点坐标
    center_x = 320
    center_y = 240
    list_position = [1, 0]  # 第一个表示上下，true是上，第二个表示左右，true是左
    '''if(Y<center_y):
        list_position[0]=0
    if(Y>center_y):
        list_position[0]=1'''
    for i in range(50):
        if (X < center_x-10):  # 往左走
            send_data = "1557:1495:1520:1520:100:090"
            print(X,"向左走")
        if (X > center_x + 10):  # 网右转
            send_data = "1576:1510:1520:1520:100:090"
            print(X,"往右走")
        else:  # 直走
            send_data = "1560:1505:1520:1520:100:090"
            print(X,"直走")
        udp_socket.sendto(send_data.encode('utf-8'), ip_adders)

